<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>钥匙分享记录</title>
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
    <meta name="renderer" content="webkit">
    <link href="${pageContext.request.contextPath}/static/css/common.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/plugins/bootstrap-3.3.5/css/bootstrap.min.css"
          rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/plugins/font-awesome-4.3.0/css/font-awesome.min.css"
          rel="stylesheet">
    <!-- jqgrid-->
    <link href="${pageContext.request.contextPath}/static/plugins/jqGrid/css/custom.ui.jqgrid.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/plugins/layer/skin/layer.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/plugins/jqGrid/css/style.css" rel="stylesheet">

    <script src="${pageContext.request.contextPath}/static/js/jquery-1.11.3.min.js"></script>
    <script src="${pageContext.request.contextPath}/static/js/jquery.form.js"></script>
    <script src="${pageContext.request.contextPath}/static/js/common.js"></script>
    <script src="${pageContext.request.contextPath}/static/plugins/bootstrap-3.3.5/js/bootstrap.min.js"></script>
    <script src="${pageContext.request.contextPath}/static/plugins/jqGrid/js/i18n/grid.locale-cn.js"></script>
    <script src="${pageContext.request.contextPath}/static/plugins/jqGrid/js/minified/jquery.jqGrid.min.js"></script>
    <script src="${pageContext.request.contextPath}/static/plugins/layer/layer.js" type="text/javascript"></script>
 	<script src="${pageContext.request.contextPath}/static/js/global.js"></script>
    <script type="text/javascript"
            src="${pageContext.request.contextPath}/static/plugins/My97DatePicker/WdatePicker.js"></script>
    
</head>
<body>
<div class="col-sm-12">
    <div class="jqGrid_wrapper">
     	<h1>钥匙分享记录</h1>
        <table id="jqGrid" style="font-size: 12px !important;"></table>
    </div>
</div>
<script type="text/javascript">
$(document).ready(
        function () {
        	$.jgrid.defaults.styleUI = "Bootstrap";
        	
            $("#jqGrid").jqGrid(
                    {
                        url: "${pageContext.request.contextPath}/admin/tkeys_shareKeys.action?userId=${userId}&pid=${pid}",
                        mtype: 'POST',
                        datatype: "json",
                        height:350,
                        autowidth: true,
                        shrinkToFit: true,
                        rowNum: 10,
                        rowList: [10, 20, 30],
                        colNames: ['序号', '门禁名称', '硬件PID', '访客有效截止时间', '分享时间', '钥匙领取', '钥匙领取时间'],
                        colModel: [{
                            name: "SID",
                            index: "SID",
                            key: true,
                            hidden: true
                        }, {
                            name: 'LOCKNAME',
                            index: 'LOCKNAME'
                        }, {
                            name: 'PID',
                            index: 'PID',
                        }, {
                            name: 'EXPIRETIME',
                            index: 'EXPIRETIME',
                        }, {
                            name: 'CREATETIME',
                            index: 'CREATETIME',
                        }, {
                            name: 'BINDMIRRORUSERTIME',
                            index: 'BINDMIRRORUSERTIME',
                            formatter: function (cellvalue, options, rawObject) {
                            	if(cellvalue == '-1'){
                                 	return '';
                                }else if(!cellvalue){
                            		return  '未领取';
                            	}else{
                            		return '已领取';
                            	}
                            }
                        }, {
                            name: 'BINDMIRRORUSERTIME',
                            index: 'BINDMIRRORUSERTIME',
                            formatter: function (cellvalue, options, rawObject) {
                            	if(cellvalue == '-1' || !cellvalue){
                                 	return '';
                                }else{
                            		return cellvalue;
                            	}
                            }
                        }],
                        sortname: 't.sid',
                        sortorder: 'desc',
                        rownumbers: true,
                        jsonReader: {
                            root: 'rows',
                            page: "page",
                            total: 'total',
                            records: "records",
                            repeatitems: false
                        },
                        pager: "#jqGrid_paper",
                        viewrecords: true,
                        multiselect: true,
                        hidegrid: false,
                        loadComplete: function(){
                    		var re_records = Number($("#jqGrid").getGridParam('records'));
                    		var page = Number($("#jqGrid").getGridParam('page'));
                    		var rows=Number($("#jqGrid").getGridParam('rowNum'));
                    		var num = re_records-(page-1)*rows;
                    		if(num < rows)
                    		{
                    			for(var i=num;i<rows;i++){
                    				$("#jqGrid").jqGrid("addRowData",(i+1),
                            				{ SID:"",LOCKNAME:"",PID:"",EXPIRETIME:"",CREATETIME:"",BINDMIRRORUSERTIME:"-1"}
                    				,"");
                    			}
                    			$(".ui-paging-info").html(re_records-num+1 +" - "+re_records+"　共 "+re_records+" 条");
                    		}
                    	}
                    });
            $(".ui-jqgrid-htable").attr("style","font-size: 12px !important;");
		
        });
        
</script>
</body>
</html>
